package game.players.cpu.opponent;

import com.uqbar.vainilla.DeltaState;

import game.ball.SoccerBall;
import game.players.SoccerPlayer;
import game.players.states.CPUOppWithoutBall;

public abstract class WithoutBallAbstractMovingCPUOpp extends CPUOppWithoutBall {
	
	private double x;
	private double y;

	public WithoutBallAbstractMovingCPUOpp(SoccerPlayer player, double x, double y) {
		super(player);
		this.setX(x);
		this.setY(y);
	}
	
	@Override
	public void update(DeltaState deltaState) {
		this.getPlayer().move(this.getX(), this.getY());
		
		SoccerBall ball = this.getPlayer().getScene().getSoccerBall();
		if (this.getPlayer().getScene().isMateOfWithBall(this.getPlayer())) {
			if (this.isAtDistanceFromTheArc(this.getPlayer().getRivalArc(), 0, 300))
				this.changeToTheRivalArcWith(0, this.getPlayer().getMovementSpeed());
		}
		else {
			if (this.isAtDistanceFromTheBall(ball, 75, 25) && !ball.isFree() && this.getPlayer().getScene().isBallOnGame())
				this.getPlayer().setState(new WithoutBallSweepingCPUOpp(this.getPlayer(), this.getPlayer().getState().isRight()));
		}
		
		super.update(deltaState);
	}
	
	
	
	

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

	
}
